package com.vilen.learn.java7;

import java.io.IOException;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by vilen on 2017/9/16.
 */
public class Listing_2_1 {
    public static void main(String[] args) {
        Path listing = Paths.get("D:\\test.txt");
        System.out.println("Filename [ " + listing.getFileName() +" ]");
        // 获取名称元素的数量
        System.out.println("Number of Name Elements in the Path ["+listing.getNameCount() +"]");
        // 获取 path 的信息
        System.out.println(listing.getParent());
        System.out.println(listing.getRoot());

        System.out.println(listing.subpath(0,1));

        Path listing2 = Paths.get("C:\\Users\\vilen\\Desktop\\常用程序\\Anki.lnk");
        System.out.println("Filename [ " + listing2.getFileName() +" ]");
        // 获取名称元素的数量
        System.out.println("Number of Name Elements in the Path ["+listing2.getNameCount() +"]");
        // 获取 path 的信息
        System.out.println(listing2.getParent());
        System.out.println(listing2.getRoot());
        System.out.println(listing2.subpath(0,2));
        try {
            System.out.println(listing2.toRealPath());
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
